import Vue from "vue";
import Vuex from "vuex";
import Tableindex from "./table/index.js";
import Userindex from "./userinfo/index.js";
import createPersistedstate from "vuex-persistedstate";
Vue.use(Vuex);

export default new Vuex.Store({
  modules: {
    Tableindex,
    Userindex
  },
  getters: {
    token: (state) => state.Userindex.token,
    username: (state) => state.Userindex.user.userName,
    role:(state)=> state.Userindex.roles.join(''),
    equipmentName:(state)=>state.Userindex.equipmentName,
    equipmentId:(state)=>state.Userindex.equipmentId
  },
  actions: {
    logout({ commit }) {
      commit("Userindex/LOGOUT", null, { root: true });
    },
  },
  plugins: [
    createPersistedstate({
      key:'dstore',
      storage: window.localStorage,
    }),
  ],
});
